$(function () {
    getNewsPlateData();
})

function getNewsPlateData() {
    $.ajax({
        url: '/newsPlateSelect',
        data: "",
        type: 'get',
        dataType: 'json',
        success: function (data) {
            setPlateSelectData(data);
        }
    })
}

function setPlateSelectData(data) {
    let html = "";
    for (let i = 0; i < data.length; i++) {
        html += '    <tr>\n' +
            '            <td>' + data[i].id + '</td>\n' +
            '            <td>' + data[i].name + '</td>\n' +
            '            <td>' + data[i].createTime + '</td>\n' +
            '            <td>' + (data[i].status == 1 ? '启用' : '停用') + '</td>\n' +
            '            <td><a href="javascript:toUserEdit(' + data[i].id + ')"> 编辑</a>  ' +
            '<a href="javascript:UserDel(' + data[i].id + ')" >删除</a></td>\n' +
            '        </tr>';
    }
    console.log(html);
    $("#plateData").html(html);
}
function toPlateEdit(id) {
    localStorage.setItem("plateId", id);
    $('#backright').load('/back/newsPlateSelect.jsp');
}
function plateDel(id) {
    $.ajax({
        url: '/delPlateById',
        data: {id: id},
        type: 'post',
        dataType: 'json',
        success: function (data) {
            alert(data[0].result);
            $('#backright').load('/back/newsPlateSelect.jsp');
        }
    })
}